<?php
class Control_AnnounceData_view {

	function view() {
		$fileName = MooForm::request('fileName');
		$dirPath = ROOT_PATH . "/notices/";
		$filePath = $dirPath . $fileName;
		
		$data = array();
		while(false !== ($line = MooFile::readLine($filePath))) {
			if (!$line) {
				continue;
			}
			$tmpArr = array();
			$lineArr = explode('	', $line);
			$data[$lineArr[1]] = $lineArr;
		}
		
		$dataValues = array();
		foreach ($data as $k => $v) {
			if($v[0] == "id") {
				$index = 0;
			} else {
				$index = $v[0];
			}
			$dataValues[$index] = $v;
		}
		
		ksort($dataValues);
		unset($dataValues[0]);
		
		$res = "";
		foreach ($dataValues as $key => $val) {
			$res = $res . $val[2];
		}
		
		$res = str_replace("\n", "<br/>", $res);
		
		MooView::set('viewData', $res);
		MooView::render('announceView');
	}
}